<?
require_once("conn.php");
$id = $_REQUEST["id"];
?>
<script>

	function checkState(id){
		var x = $("input:checked[name=accept_check_"+id+"]").val();
		if(x == "2"){
			document.getElementById('real_amount_'+id).disabled = false;
			$("#real_amount_"+id).focus();
		}else{
			$("#real_amount_"+id).val("");
			document.getElementById('real_amount_'+id).disabled = true;
		}
	}
	
</script>
<table id="tbl_accept_list" border="1">
	<tr>
		<th width="100">Barcode</th>
		<th width="300">Item</th>
		<th width="50">Amount</th>
		<th width="50">Unit</th>
		<th width="300">&nbsp;</th>
	</tr>
	<?
		$sql = "SELECT a.id as id,b.id as product_id,barcode,th,mm,amount,unit_name FROM (pch_sendisland_detail as a join product as b on a.item=b.id) join pch_unit as c on a.unit=c.id where send_id='".$id."' ORDER BY a.id;";
		$query = mysql_query($sql);
		while($row = mysql_fetch_array($query)){

	?>
	<tr>
		<td align="center"><?=$row["barcode"]?></td>
		<td><?=$row["th"]." | ".$row["mm"]?></td>
		<td align="center"><?=$row["amount"]?></td>
		<td align="center"><?=$row["unit_name"]?></td>
		<td align="center">
			<input type="hidden" id="proid_<?=$row["id"]?>" value="<?=$row["product_id"]?>">
			<input type="hidden" id="pro_amount_<?=$row["id"]?>" value="<?=$row["amount"]?>">			
			<input type="radio" name="accept_check_<?=$row["id"]?>" id="accept_check_a_<?=$row["id"]?>" value="1" onclick="checkState('<?=$row["id"]?>')" checked><label for="1">Accept</label>&nbsp;
			<input type="radio" name="accept_check_<?=$row["id"]?>" id="accept_check_b_<?=$row["id"]?>" value="2" onclick="checkState('<?=$row["id"]?>')"><label for="2">NotAccpet</label>
			<input type="text" id="real_amount_<?=$row["id"]?>" width="90" onkeypress="return numbersonly(event)" disabled>
		</td>
	</tr>
	<?
		}
	?>
</table>
<table>
	<tr>
		<th colspan="5">Not In List</th>
	</tr>
	<tr>
		<td colspan="5">
			<input type="hidden" id="a_last_row" value="1">
			<table id="a_unknow">
				<tr>
					<td>Barcode</td>
					<td>Product</td>
					<td>Amount</td>
					<td>Unit</td>
					<td>&nbsp;</td>
				</tr>
				<tr id="a_rows_1">
					<td><input type="text" id="a_barcode_1"></td>
					<td><input type="text" id="a_product_1"></td>
					<td><input type="text" id="a_amount_1" onkeypress="return numbersonly(event)"></td>
					<td><input type="text" id="a_unit_1"></td>
					<td id="a_row_1"><input type="button" value="Add" onclick="newRowUnknow()"></td>
				</tr>
			</table>
		</td>
	</tr>
	<tr>
		<td colspan="5"><input type="button" value="Accept" onclick="checkAccept('<?=$id?>')"></td>
	</tr>
</table>